package com.atguigu.gmall.weball.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.servlet.http.HttpSession;
import javax.websocket.server.PathParam;

/**
 * @ClassName LalaController
 * @Description TODO
 * @Author king
 * @Date 2022/11/14 18:39
 * @Version 1.0
 */
@Controller
public class LalaController {

    @GetMapping("/lala")
    public String lala(){
        return "lala";
    }

    final static String LOGIN_USER = "loginUser";

    @GetMapping("/lalapage")
    public String lalaPage(@PathParam("username") String username, HttpSession session){
        session.setAttribute(LOGIN_USER, username);

        return "lala";
    }

    @GetMapping("/whoiam")
    public String whoiam(HttpSession session, Model model){
        Object attribute = session.getAttribute(LOGIN_USER);
        model.addAttribute("msg", attribute);
        return "lala";
    }

}
